home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / pvm34b3.zip / pvm34b3 / pvm3 / gexamples / joinleave.c < prev    next >
C/C++ Source or Header  |  1997-07-22  |  2KB  |  74 lines

  1.  
  2. static char rcsid[] =
  3.     "$Id: joinleave.c,v 1.2 1997/07/09 13:27:59 pvmsrc Exp $";
  4.  
  5. /*
  6.  *         PVM version 3.4:  Parallel Virtual Machine System
  7.  *               University of Tennessee, Knoxville TN.
  8.  *           Oak Ridge National Laboratory, Oak Ridge TN.
  9.  *                   Emory University, Atlanta GA.
  10.  *      Authors:  J. J. Dongarra, G. E. Fagg, M. Fischer
  11.  *          G. A. Geist, J. A. Kohl, R. J. Manchek, P. Mucci,
  12.  *         P. M. Papadopoulos, S. L. Scott, and V. S. Sunderam
  13.  *                   (C) 1997 All Rights Reserved
  14.  *
  15.  *                              NOTICE
  16.  *
  17.  * Permission to use, copy, modify, and distribute this software and
  18.  * its documentation for any purpose and without fee is hereby granted
  19.  * provided that the above copyright notice appear in all copies and
  20.  * that both the copyright notice and this permission notice appear in
  21.  * supporting documentation.
  22.  *
  23.  * Neither the Institutions (Emory University, Oak Ridge National
  24.  * Laboratory, and University of Tennessee) nor the Authors make any
  25.  * representations about the suitability of this software for any
  26.  * purpose.  This software is provided ``as is'' without express or
  27.  * implied warranty.
  28.  *
  29.  * PVM version 3 was funded in part by the U.S. Department of Energy,
  30.  * the National Science Foundation and the State of Tennessee.
  31.  */
  32.  
  33. /*
  34.     join and leave a lot 
  35.  
  36. */
  37.  
  38. #include <stdio.h>
  39. #include "pvm3.h"
  40. #define MAXJOINS 10000
  41. int
  42. main(argc, argv)
  43. int argc;
  44. char *argv[];
  45. {
  46.     int mytid, mygid, njoins;
  47.     int cnt = 0;
  48.  
  49.     mytid = pvm_mytid();
  50.     fprintf(stderr, "%s 0x%x enrolled\n", argv[0], mytid);
  51.     if (mytid < 0) {
  52.         pvm_perror(argv[0]);
  53.         return -1;
  54.         }
  55.         if (argc > 1)
  56.            njoins = atoi(argv[1]);
  57.         else
  58.            njoins = MAXJOINS;
  59.  
  60.     /* join a group */
  61.     while (cnt++ <= njoins) {
  62.         if((mygid = pvm_joingroup("JoinLeave")) < 0) {
  63.             pvm_perror("JoinLeave");
  64.             break;
  65.             }
  66.         if((mygid = pvm_lvgroup("JoinLeave")) < 0) {
  67.             pvm_perror("JoinLeave");
  68.             break;
  69.             }
  70.         if ((cnt%100)==0) printf("Joined %d times\n", cnt);
  71.         }
  72.  
  73. }
  74.